﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace laba2.Entity
{
    public class Achivement : Entity
    {

        public int TaskId { get; set; }
        private Task _task;
        private DateTime _date;
        private int _rating;
        public int StudentId { get; set; }
        private Student _student;

        public Achivement(int id, Task task, DateTime date, int rating, Student student) : base(id)
        {
            this._task = task;
            _date = date;
            _rating = rating;
            _student = student;
        }

        public Achivement(DateTime date, Task task, int rating, Student student)
        {
            _date = date;
            _task = task;
            _rating = rating;
            _student = student;
        }

        public Achivement(DateTime date, int rating, int taskId, int studentId)
        {
            _date = date;
            _rating = rating;
            TaskId = taskId;
            StudentId = studentId;
        }

        public static Achivement CreatePracticalTask(int taskId, DateTime date, int ratingForQuality, int ratingForDate,int studentId)
        {
            return new Achivement(date, ratingForDate + ratingForQuality, taskId, studentId);
        }
        public static Achivement CreateBoundaryControl(int taskId, DateTime date, int rating, int studentId)
        {
            return new Achivement(date, rating, taskId, studentId);
        }
        public static Achivement CreateFinalControl(int taskId , DateTime date, int rating, int studentId )
        {
            return new Achivement(date, rating, taskId, studentId);
        }

        public Achivement()
        {
        }

        public Student Student
        {
            get { return _student; }
            set { _student = value; }
        }

        public int Rating
        {
            get { return _rating; }
            set { _rating = value; }
        }

        public DateTime Date
        {
            get { return _date; }
            set { _date = value; }
        }

        public Task Task
        {
            get { return _task; }
            set { _task = value; }
        }

        public bool isPass()
        {
            return _rating >= _task.PassingRating;
        }
    }
}
